package com.axzhengxin.platform.afterloan.transf;

import cn.hutool.core.map.MapUtil;
import com.axzhengxin.platform.afterloan.domain.RiskModelResult;
import lombok.Data;

import java.util.Map;

/**
 * RiskDataDetail
 * 客户详情页预警信息列表数据对象
 *
 * @author jiangnan
 * @date 2021/3/22
 */
@Data
public class RiskDataDetail {

    private static final Map<String, String> RISK_LEVEL_MAPPER = MapUtil
            .<String, String>builder()
            .put("一级", "1")
            .put("二级", "2")
            .put("三级", "3")
            .build();

    /**
     * 主键
     */
    private Integer id;
    /**
     * 序号
     */
    private Integer index;
    /**
     * 预警信息日期
     */
    private String warnDate;
    /**
     * 预警级别（颜色）
     */
    private String warnLevel;
    /**
     * 预警信号内容
     */
    private String warnSignal;

    /**
     * 预警信号状态
     */
    private String signalStatus;

    public static RiskDataDetail init(RiskModelResult result) {
        RiskDataDetail detail = new RiskDataDetail();
        detail.setId(result.getId());
        detail.setWarnDate(result.getBatchDate());
        detail.setWarnLevel(RISK_LEVEL_MAPPER.getOrDefault(result.getRuleLevel(), "3"));
        detail.setWarnSignal(result.getBatchRuleName());
        detail.setSignalStatus(result.getSignalStatus());
        return detail;
    }

}
